package com.zprmb.udzt;

import org.json.JSONObject;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.RelativeLayout;

import com.handmark.pulltorefresh.library.PullToRefreshBase;
import com.handmark.pulltorefresh.library.PullToRefreshBase.Mode;
import com.handmark.pulltorefresh.library.PullToRefreshBase.OnRefreshListener2;
import com.handmark.pulltorefresh.library.PullToRefreshListView;
import com.zprmb.udzt.http.AjaxParams;
import com.zprmb.udzt.util.Constant;
import com.zprmb.udzt.util.VolleryUtil;
/**
 * 回款
 * @author shenshao
 *
 */
public class Money_transfer extends BaseActivity implements OnRefreshListener2<ListView>,OnClickListener{
	private PullToRefreshListView lv;
	private ImageView img_back;
	private RelativeLayout rl_back;
	private ListView listView;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.money_transfer);
		 BbtApplication.getInstance().addActvity(this);
		lv=(PullToRefreshListView)findViewById(R.id.lv);
		listView=lv.getRefreshableView();
		img_back=(ImageView)findViewById(R.id.img_back);
		registerForContextMenu(listView);
		img_back.setOnClickListener(this);
		lv.setOnRefreshListener(this);
		lv.setOnRefreshListener(this);
		lv.setMode(Mode.BOTH);
		rl_back=(RelativeLayout)findViewById(R.id.rl_back);
		rl_back.setOnClickListener(this);
		initData();
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		BbtApplication.getInstance().removeActvity(this);
	}
	private void initData() {
		// TODO Auto-generated method stub
		VolleryUtil volleryUtil=new VolleryUtil() {
			
			@Override
			public void onUpDate(JSONObject jsonObject) {
				// TODO Auto-generated method stub
				Log.e("ss", jsonObject.toString());
			}
			
			@Override
			public void onError() {
				// TODO Auto-generated method stub
				
			}
		};
		volleryUtil.setHeaders("token",getToken());
		volleryUtil.setRequestMethod(0);
		if(getIntent().getStringExtra("ptype").equals("claim")){
			AjaxParams params=new AjaxParams();
			params.put("investId", getIntent().getStringExtra("investId"));
			volleryUtil.execute(Money_transfer.this, Constant.URL+"/api/v2/claim/repayDataDetail", "?"+params.toString());
		}else if(getIntent().getStringExtra("ptype").equals("uplan")){
			AjaxParams params=new AjaxParams();
			params.put("id", getIntent().getStringExtra("id"));
			params.put("type", getIntent().getStringExtra("type"));
			volleryUtil.execute(Money_transfer.this, Constant.URL+"/api/v2/claim/repayDataDetail", "?"+params.toString());
			
		}else if(getIntent().getStringExtra("ptype").equals("invest")){
			AjaxParams params=new AjaxParams();
			params.put("id", getIntent().getStringExtra("id"));
			params.put("type", getIntent().getStringExtra("type"));
			volleryUtil.execute(Money_transfer.this, Constant.URL+"/api/v2/claim/repayDataDetail", "?"+params.toString());
			
		}
		
	}

	@Override
	public void onPullDownToRefresh(PullToRefreshBase<ListView> refreshView) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void onPullUpToRefresh(PullToRefreshBase<ListView> refreshView) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.img_back:
			finish();
			break;
		case R.id.rl_back:
			finish();
			break;
		}
	}
	

}
